import Vue from 'vue'
import {FootList} from './index'
// 挂载正则
import {reg} from "@/utils/vaildate"
import {mapState,mapMutations} from 'vuex'
import {ShowError,ShowSuccess} from "@/API/request"

Vue.mixin({
    data(){
        return{
            FootList:FootList,
            reg
        }
    },
    methods:{
        ShowError,
        ShowSuccess,
        gotopage(name){
            this.$router.push({name})
        },
        gotodown(){
            this.$router.go(-1)
        },
         gotofilm(byid){
            // this.$router.push({name}),
            this.$router.push({name:"film",query:{ids:byid}})
            // this.changeUserInfo(byid);
            // localStorage.setItem("ids", JSON.stringify(byid));
        },
        // 全局组件混入 在其他地方可以直接调用
        ...mapMutations(
            [
                'changeUserInfo',
                'changeCity',
                'changeCityList',
                'changeFromRoute',
                'changecartList'
            ]
        ),
        checkHasLogined(callback){
            if(this.userInfo){
                //请求数据的回调
                callback()
            }else{
                this.$dialog.alert({
                    title:'登录提示',
                    message:'你尚未登录请前往登录',
                }).then(()=>{
                    this.$router.push({name:'login'})
                })
            }
        }
    },
    mounted(){

    },
    computed:{
        ...mapState([
            'cartNum',
            'userInfo',
            'city',
            'cityList',
            'cartList'
        ])
    },
})